package c.d.a.a.j;

import android.graphics.Paint;
import android.graphics.Paint.FontMetrics;
import android.graphics.Rect;
import android.util.DisplayMetrics;
import android.util.Log;
import c.d.a.a.d.c;
import c.d.a.a.d.e;

/* compiled from: Utils */
public abstract class g {
    public static DisplayMetrics a = null;
    public static int b = 50;
    public static int c = 8000;
    public static final float d = Float.intBitsToFloat(1);
    public static Rect e = new Rect();
    public static FontMetrics f = new FontMetrics();
    public static Rect g = new Rect();
    public static e h = new c(1);
    public static Rect i = new Rect();
    public static Rect j = new Rect();
    public static FontMetrics k = new FontMetrics();

    static {
        Double.longBitsToDouble(1);
    }

    public static int a(Paint paint, String str) {
        Rect rect = e;
        rect.set(0, 0, 0, 0);
        paint.getTextBounds(str, 0, str.length(), rect);
        return rect.height();
    }

    public static b b(Paint paint, String str) {
        b b = b.b(0.0f, 0.0f);
        Rect rect = g;
        rect.set(0, 0, 0, 0);
        paint.getTextBounds(str, 0, str.length(), rect);
        b.b = (float) rect.width();
        b.c = (float) rect.height();
        return b;
    }

    public static int c(Paint paint, String str) {
        return (int) paint.measureText(str);
    }

    public static float d(float f) {
        DisplayMetrics displayMetrics = a;
        if (displayMetrics != null) {
            return f * displayMetrics.density;
        }
        Log.e("MPChartLib-Utils", "Utils NOT INITIALIZED. You need to call Utils.init(...) at least once before calling Utils.convertDpToPixel(...). Otherwise conversion does not take place.");
        return f;
    }

    public static float e(float f) {
        while (f < 0.0f) {
            f += 360.0f;
        }
        return f % 360.0f;
    }

    public static void f(d dVar, float f, float f2, d dVar2) {
        double d = (double) f;
        double d2 = (double) f2;
        dVar2.b = (float) ((Math.cos(Math.toRadians(d2)) * d) + ((double) dVar.b));
        dVar2.c = (float) ((Math.sin(Math.toRadians(d2)) * d) + ((double) dVar.c));
    }

    public static b g(float f, float f2, float f3) {
        double d = (double) (f3 * 0.017453292f);
        return b.b(Math.abs(((float) Math.sin(d)) * f2) + Math.abs(((float) Math.cos(d)) * f), Math.abs(f2 * ((float) Math.cos(d))) + Math.abs(f * ((float) Math.sin(d))));
    }

    public static double h(double d) {
        if (d == Double.POSITIVE_INFINITY) {
            return d;
        }
        d += 0.0d;
        return Double.longBitsToDouble(Double.doubleToRawLongBits(d) + (d >= 0.0d ? 1 : -1));
    }

    public static float i(double d) {
        if (Double.isInfinite(d) || Double.isNaN(d) || d == 0.0d) {
            return 0.0f;
        }
        float pow = (float) Math.pow(10.0d, (double) (1 - ((int) ((float) Math.ceil((double) ((float) Math.log10(d < 0.0d ? -d : d)))))));
        return ((float) Math.round(d * ((double) pow))) / pow;
    }
}
